package com.zjw.algorithm.test;

import com.zjw.algorithm.utils.ByteArrayBuffer;

import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class T1 {

    public static void main(String[] args) {
        byte[] bytes = "dwdhawidhiawodhaiw".getBytes(StandardCharsets.UTF_8);

        ByteArrayBuffer buffer = new ByteArrayBuffer();

        System.out.println(Arrays.toString(buffer.toByteArray()));
        ByteBuffer allocate = ByteBuffer.allocate(4 + bytes.length);
        allocate.putInt(Integer.MAX_VALUE);

        buffer.appendInt(Integer.MAX_VALUE);


        allocate.put(bytes);

        System.out.println(Arrays.toString(allocate.array()));
    }


    public static String fromObject(Object o) {
        if (o == null) {
            return "null";
        }

        return o.toString();
    }
}
